package com.shigui.news.model;

import java.util.Set;

import org.apache.struts2.json.annotations.JSONFieldBridge;

import com.shigui.news.utils.MD5;

public class User {
	public static final String SESSION_PERSIST_KEY = "session_persist_key";
	public static final String SESSION_USER_KEY = "session_user_key";
	
//	private static final String JOB_NO_FORMAT = "00000";
//	private static final int JOB_NO_MIN_LENGTH = 5;
	
	private Integer id;
	private String username;
	private String password;
	private String cipherPassword;
	private String email;
	private String phone;
	private Float age;
	private String sex;
	private String address;
	private String type;
	private String persistCode;
	
	private Set<Comment> comments;
	
	
	public Set<Comment> getComments() {
		return comments;
	}

	public void setComments(Set<Comment> comments) {
		this.comments = comments;
	}
	

	public User(){
		
	}
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		try {
			
			this.cipherPassword = MD5.encode(password);
			
		} catch (Exception e) {

			e.printStackTrace();
		}
		this.password = password;
	}
	
	
	public String getCipherPassword() {
		return cipherPassword;
	}
	public void setCipherPassword(String cipherPassword) {
		this.cipherPassword = cipherPassword;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public Float getAge() {
		return age;
	}
	public void setAge(Float age) {
		this.age = age;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getPersistCode() {
		return persistCode;
	}
	public void setPersistCode(String persistCode) {
		this.persistCode = persistCode;
	}
	
	public void createPersistCode(){
		try {
			
			String persistCode = MD5.encode(getPhone()+System.currentTimeMillis()+Math.random());
			setPersistCode(persistCode);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}
	
	
	
}
	



